1. Field of the Invention
The present invention relates to a method and an apparatus for processing messages.
2. Description of the Related Art
In recent times, various services are provided through computer networks. Currently, web service related techniques are attracting attention. A Web Service is a mechanism for allowing computers to dynamically exchange data by using various protocols, typified by HTTP, without manual operation. In a Web Service, SOAP messages flow on a communication protocol to allow various computer devices, built-in devices, and the like to simultaneously receive different pieces of information.
Since a SOAP message is generated in Extensible Markup Language (XML), some contrivance is required to transmit binary data, such as image data. In general, the following methods are used: a method of converting binary data into a character string on the basis of base64 or the like, and embedding the converted data in XML, to be referred to as the character string conversion method hereinafter, and a method using an attached file such as a MIME multi-part file, to be referred to as the file attachment method hereinafter.
The character string conversion method has a problem, in that it requires a processing time overhead to convert binary data into a character string, or to convert a character string back into binary data, depending on the size of the binary data. Therefore, the latter file attachment method is more generally used to transmit or receive large-volume binary data together with a SOAP message.
The file attachment method transmits a SOAP message and an attached file as one message, via a communication protocol such as HTTP. Note that the message is segmented into a SOAP message fragment and an attached file fragment by a delimiter character string that is determined by a specification. When attaching an attached file, the file attachment method can attach binary data to a message without requiring conversion. The file attachment method therefore need not perform processing such as converting binary data into a character string or restoring binary data from a character string, and hence has a advantage of high processing efficiency, compared with the character string conversion method.
In the file attachment method, a SOAP message moving over the communication protocol is packaged in a non-XML format as a message format for attached files, e.g., the MIME multi-part format. For this reason, applications and libraries designed to handle only XML cannot process messages based on the file attachment method. In addition, according to specifications designed to handle only XML, such as WS-BPEL or XPath as well, a message generated by the file attachment method does not have a structure as an XML structure as a whole, and hence, some inconvenience occurs.
In general, a program, library, or the like which handles XML is programmed by using a Document Object Model (DOM) interface, as defined by W3C. A DOM interface is an interface standardized to allow access from a program to XML data. A program or library that supports a DOM interface can directly exchange data, or can easily convert data and use the resultant data, even though it cannot directly exchange the data.
A DOM interface can perform processing by tracking back an XML tree structure, and hence can be used for XML for general purposes. However, as described above, a message with an attached file has a SOAP message contained in part of the content, but expresses an attached file as a MIME multi-part file as a whole. Hence, it is generally impossible to operate the overall message by using the DOM interface. In such a case, in general, an attached file is separated from a SOAP message to allow to handle only the SOAP message portion as an XML data by using the DOM interface.
As described above, when large-volume binary data, such as image data, is to be handled in a Web Service, communication is generally performed with minimum processing overhead by using the file attachment method. This method, however, allows using a DOM interface only for a SOAP message separated from a message in, for example, the MIME multi-part format. That is, the method allows using a DOM interface based on a general XML processing method for only a part of a message. Inability to use DOM amounts to inability to use general-purpose libraries. This leads to a considerable deterioration in the reuse efficiency of a program. In addition, this causes inconvenience in the WS-BPEL specifications, the XPath specifications, and the like, based on the assumption that they handle XML. Therefore, handling binary data in messaging using SOAP leads to a considerable increase in development load.